import Vue from 'vue'
// /* eslint disable */
// 联系房东
contactLandlor = (landlordId) => {
	let mobileTo = ''
	Vue.$axiosPosting(Vue.api.getUserById, {userId: landlordId}).then(res => {
	  if (res.code === '0000') {
	    mobileTo= res.data.mobile
	  }
	})
	let userInfo = JSON.parse(window.localStorage.getItem('userInfo'))
	let mobileFor = userInfo ? userInfo.mobile : ''
	let virtualNum = ''
	if (mobileFor) {
	  if (virtualNum === '') {
	    Vue.axiosPost(Vue.api.getVirtualNum, {mobileFor, mobileTo: mobileTo}).then(res => {
	      let data = ''
	      if (res.code === '0000') {
	        data = JSON.parse(res.data)
	      }
	      if (res.code === '0000' && data.errorCode === '0') {
	        virtualNum = data.virtualNum
	        window.location.href = `tel:${virtualNum}`
	      } else {
	        Vue.$vux.toast.text('无法获取房东电话')
	        virtualNum = ''
	      }
	    })
	  } else {
	    window.location.href = `tel:${virtualNum}`
	  }
	} else {
	  Vue.$router.replace('/login')
	}
}

Vue.contactLandlor = contactLandlor
// /* eslint enable */